
use Data_US

***********************
//RECODING VARIABLES//
***********************

//Independent variable: Discrimination type
generate byte disc =.
replace disc = 1 if tb_1 !=.
replace disc = 2 if tba_1 !=.
replace disc = 3 if tbi_1 !=.
replace disc = 4 if st_1 !=.
replace disc = 5 if sta_1 !=.
replace disc = 6 if sti_1 !=.
codebook disc

recode disc (1=1 "Taste-based") (2=2 "Taste-based acc") (3=3 "Taste-based inacc") (4=4 "Statistical") (5=5 "Statistical acc") (6=6 "Statistical inacc"), gen(discr)
codebook discr

//Dependent variable
generate byte accept =.

replace accept = 1 if tb_1==1 | tba_1==1 | tbi_1==1 | st_1==1 | sta_1==1 | sti_1==1
replace accept = 2 if tb_1==2 | tba_1==2 | tbi_1==2 | st_1==2 | sta_1==2 | sti_1==2
replace accept = 3 if tb_1==3 | tba_1==3 | tbi_1==3 | st_1==3 | sta_1==3 | sti_1==3
replace accept = 4 if tb_1==4 | tba_1==4 | tbi_1==4 | st_1==4 | sta_1==4 | sti_1==4
replace accept = 5 if tb_1==5 | tba_1==5 | tbi_1==5 | st_1==5 | sta_1==5 | sti_1==5
replace accept = 6 if tb_1==6 | tba_1==6 | tbi_1==6 | st_1==6 | sta_1==6 | sti_1==6
replace accept = 7 if tb_1==7 | tba_1==7 | tbi_1==7 | st_1==7 | sta_1==7 | sti_1==7
codebook accept

//DUMMY-CODING//
recode accept (1/4=0 "Unacceptable") (5/7=100 "Acceptable"), gen(acceptdummy)
recode accept (1/3=0 "Unacceptable") (4/7=100 "Not unacceptable"), gen(altacceptdummy)

//Feelings//
codebook q3_7
recode q3_7 (0/24=1 "cold") (25/49=2 "medium cold") (50/74=3 "medium warm") (75/100=4 "warm"), gen(feelings)

recode q3_7 (0/49=0 "cold") (50/100=1 "warm"), gen(dummyfeelings)
codebook dummyfeelings

//INDEX CONSTRUCTION//

*Social comparison*
codebook q2_13
recode q2_13 (1=5) (2=4) (3=3) (4=2) (5=1), gen(q2_13a)
codebook q2_13*

pwcorr q2_1 q2_2 q2_3 q2_4 q2_5 q2_6 q2_7 q2_8 q2_9 q2_10 q2_11 q2_12 q2_13a

alpha q2_1 q2_2 q2_3 q2_4 q2_5 q2_6 q2_7 q2_8 q2_9 q2_10 q2_11 q2_12 q2_13a, item casewise

alpha q2_1 q2_2 q2_3 q2_4 q2_5 q2_6 q2_7 q2_8 q2_9 q2_10 q2_11 q2_12 q2_13a, casewise gen(compindex)

codebook compindex

*DSMS*

*rational*
pwcorr q1_1 q1_2 q1_3
alpha q1_1 q1_2 q1_3, item casewise
alpha q1_1 q1_2 q1_3, casewise gen(rationindex)

*Intuitive*
pwcorr q1_4 q1_5 q1_6
alpha q1_4 q1_5 q1_6, item casewise
alpha q1_4 q1_5 q1_6, casewise gen(intuitindex)

*Dependent*
pwcorr q1_7 q1_8 q1_9
alpha q1_7 q1_8 q1_9, item casewise
alpha q1_7 q1_8 q1_9, casewise gen(depenindex)

*Avoidant*
pwcorr q1_10 q1_11 q1_12
alpha q1_10 q1_11 q1_12, item casewise
alpha q1_10 q1_11 q1_12, casewise gen(avoidindex)

*Spontaneous*
pwcorr q1_13 q1_14 q1_15
alpha q1_13 q1_14 q1_15, item casewise
alpha q1_13 q1_14 q1_15, casewise gen(snapindex)

*Principles* 
//Neither nor coded as unacceptable//
codebook q7_*
foreach x in 1 2 3 4 5 6 {
recode q7_`x' (5/7=100) (1/4=0), gen(q7_`x'dummy)
}

//neither nor coded as acceptable//
codebook q7_*
foreach x in 1 2 3 4 5 6 {
recode q7_`x' (4/7=100) (1/3=0), gen(altq7_`x'dummy)
}

//BACKGROUND VARIABLES//

//Gender
codebook gender
recode gender (1=1 "Male") (2=2 "Female"), gen(gender1)

//Education
codebook education
recode education (-3105=.), gen(edu)

//Political_party
codebook political_party
recode political_party (1/3=1 "Democrat") (6=1) (4=3 "Neither") (7=3) (5=2 "Republican") (8/10=2), gen(polparty)
codebook polparty

//Ethnicity
recode ethnicity (1=1 "White") (2=2 "Black") (3=3 "Native") (4/10=4 "Asian") (11/14=5 "Pacific Islander") (15=6 "Other") (16=.), gen(race)
recode ethnicity (16=.), gen(ethn)

//Hispanic
recode hispanic (1=0) (2/14=1) (15=.) (16=1), gen(hispan)
codebook hispan

//HHI
recode hhi (-3105=.), gen(hhi1)


**********************
//AUXILARY ANALYSIS//
**********************

//Manipulation checks//
ta discr q5_1, column chi
recode q5_1 (1 2=1 "Bribe") (3=2 "neutral") (4 5=3 "hispanics"), gen(mc1)
ta mc1 discr, column chi

codebook q6_1
recode q6_1 (1 2=100 "more") (3 4 5=0 "less"), gen(mc2)
recode q6_1 (1=5 "much more") (2=4 "more") (3=3 "neutral") (4=2 "less") (5=1 "much less"), gen(oppmc2)
ta q6_1 discr, column chi
ta mc2 discr,column chi

reg mc2 ib4.discr, r

//Excluding those not identifying correct rationale//
reg accept i.discr if (discr==1 & mc1==3) | (discr==2 & mc1==3) | (discr==3 & mc1==3) | (discr==4 & mc1==1) | (discr==5 & mc1==1) | (discr==6 & mc1==1), r
reg accept ib4.discr if (discr==1 & mc1==3) | (discr==2 & mc1==3) | (discr==3 & mc1==3) | (discr==4 & mc1==1) | (discr==5 & mc1==1) | (discr==6 & mc1==1), r

codebook discr if (discr==1 & mc1==3) | (discr==2 & mc1==3) | (discr==3 & mc1==3) | (discr==4 & mc1==1) | (discr==5 & mc1==1) | (discr==6 & mc1==1)


******************
//Main Analysis//
******************
reg accept i.discr, r
margins, over(discr)
marginsplot, scheme(plotplain) title("Moral acceptance") xtitle("Treatment groups") ytitle("Acceptance percentage") recast(bar) plotopts(barwidth(0.5) bcolor(black*0.3)) xoverhangs
 

reg accept ib4.discr, r //with the statistical control as baseline

reg acceptdummy i.discr, r
margins, over(discr)
marginsplot, scheme(plotplain) title("Moral acceptance - US Sample") xtitle("Treatment groups") ytitle("Acceptance percentage") recast(bar) plotopts(barwidth(0.5) bcolor(black*0.3)) xoverhangs
graph save i3, replace

reg altacceptdummy i.discr, r
margins, over(discr)
marginsplot, scheme(plotplain) title("No moral opposition - US Sample") xtitle("Treatment groups") ytitle("No moral opposition percentage") recast(bar) plotopts(barwidth(0.5) bcolor(black*0.3)) xoverhangs
graph save i4, replace

graph combine i3.gph i4.gph, scheme(plotplain)

******************
//Interactions//
******************

codebook q3_7

*Feelings towards Hispanics*
reg accept i.discr##c.q3_7, r //not significant

reg accept i.discr##dummyfeelings, r //not significant
reg acceptdummy i.discr##dummyfeelings, r //not significant

reg accept ib4.discr##dummyfeelings, r //not significant with stat as reference
reg acceptdummy ib4.discr##dummyfeelings, r //not significant with stat as reference

reg accept i.discr##dummyfeelings, r
margins discr#dummyfeelings
marginsplot, recast(bar) by(dummyfeelings) scheme(plotplain) title("Moral assessment across discrimination types - US Sample") xtitle("Treatment groups") ytitle("Moral acceptance")

reg acceptdummy i.discr##dummyfeelings, r
margins discr#dummyfeelings
marginsplot, recast(bar) by(dummyfeelings) scheme(plotplain) title("Moral assessment across discrimination types - US Sample") xtitle("Treatment groups") ytitle("Moral acceptance")

*Social comparison*
sum compindex, detail
hist compindex
reg accept i.discr##c.compindex, r
reg accept ib4.discr##c.compindex, r

reg acceptdummy i.discr##c.compindex, r
reg acceptdummy ib4.discr##c.compindex, r

*GDMS*
hist rationindex
hist intuitindex
hist depenindex
hist avoidindex
hist snapindex

reg accept i.discr##c.rationindex, r
reg accept ib4.discr##c.rationindex, r

reg accept i.discr##c.intuitindex, r
reg accept ib4.discr##c.intuitindex, r

reg accept i.discr##c.depenindex, r
reg accept ib4.discr##c.depenindex, r

reg accept i.discr##c.avoidindex, r
reg accept ib4.discr##c.avoidindex, r

reg accept i.discr##c.snapindex, r
reg accept ib4.discr##c.snapindex, r

